﻿using System;
namespace IWMAG.Core.EnhancedProperties.PropertyNodes
{
    internal abstract class PropertyNode<T> : PropertyNode
    {
        public PropertyNode(int priority)
        {
            Previous = null;
            Next = null;
            Priority = priority;
        }


        public abstract T GetNodeValue();

        public abstract void SuccessorChanged(T value);

        public readonly int Priority;
        public virtual PropertyNode<T> Previous { get; set; }
        public virtual PropertyNode<T> Next { get; set; }

        public override string ToString()
        {
            var c = this.GetNodeValue();
            return c.ToString();
        }

        public override void Dispose()
        {
            Next = null;
            Previous = null;
        }

        public virtual void NotifyListModified()
        {
            if (Previous != null)
            {
                Previous.NotifyListModified();
            }
        }
    }

    internal abstract class PropertyNode : IDisposable
    {
        public abstract void Dispose();
    }
}
